// @APIVersion 1.0.0
// @Title xpms API
// @Description xpms 后端接口
// @Contact astaxie@gmail.com
// @TermsOfServiceUrl http://beego.me/
// @License Apache 2.0
// @LicenseUrl http://www.apache.org/licenses/LICENSE-2.0.html
package routers

import (
	beego "github.com/beego/beego/v2/server/web"
	"xpms/app/auth/groups"
	"xpms/app/auth/permissions"
	"xpms/app/auth/users"
	"xpms/app/cases"
	"xpms/app/dict"
	"xpms/app/file"
	"xpms/app/projects"
	"xpms/filter"
)

func init() {
	StaticPath, _ := beego.AppConfig.String("StaticPath")
	beego.SetStaticPath("/file", StaticPath)
	beego.InsertFilter("*", beego.BeforeRouter, filter.CorsHandler())
	beego.InsertFilter("/", beego.BeforeRouter, filter.RootTree())
	beego.InsertFilter("/view/*", beego.BeforeRouter, filter.TransparentStatic())
	beego.InsertFilter("/v1/*", beego.BeforeRouter, filter.Authorizer())
	ns := beego.NewNamespace("/v1",
		beego.NSNamespace("/dict",
			beego.NSInclude(
				&dict.DictController{},
			),
		),
		beego.NSNamespace("/sys",
			beego.NSInclude(
				&users.LoginController{},
			),
		),
		beego.NSNamespace("/user",
			beego.NSInclude(
				&users.UserController{},
			),
		),
		beego.NSNamespace("/group",
			beego.NSInclude(
				&groups.ManageGroupController{},
			),
		),
		beego.NSNamespace("/group/permission",
			beego.NSInclude(
				&groups.ManageGroupPermissionController{},
			),
		),
		beego.NSNamespace("/group/user",
			beego.NSInclude(
				&groups.ManageGroupUserController{},
			),
		),
		beego.NSNamespace("/permission",
			beego.NSInclude(
				&permissions.ManagePermissionController{},
			),
		),
		beego.NSNamespace("/positions",
			beego.NSInclude(
				&users.ManagePositionController{},
			),
		),
		beego.NSNamespace("/department",
			beego.NSInclude(
				&users.ManageDepartmentController{},
			),
		),
		beego.NSNamespace("/upload",
			beego.NSInclude(
				&file.UploadFileController{},
			),
		),
		beego.NSNamespace("/project",
			beego.NSInclude(
				&projects.ManageProjectController{},
			),
		),
		beego.NSNamespace("/project/module",
			beego.NSInclude(
				&projects.ManageModuleController{},
			),
		),
		beego.NSNamespace("/project/test",
			beego.NSInclude(
				&projects.TestProjectController{},
			),
		),
		beego.NSNamespace("/project/team",
			beego.NSInclude(
				&projects.TeamProjectController{},
			),
		),
		beego.NSNamespace("/project/needs",
			beego.NSInclude(
				&projects.NeedsProjectController{},
			),
		),
		beego.NSNamespace("/project/task",
			beego.NSInclude(
				&projects.TaskProjectController{},
			),
		),
		beego.NSNamespace("/project/task/time",
			beego.NSInclude(
				&projects.TaskTimeByTaskController{},
			),
		),
		beego.NSNamespace("/project/analysis",
			beego.NSInclude(
				&projects.ProjectAnalysisController{},
			),
		),
		beego.NSNamespace("/project/plan",
			beego.NSInclude(
				&projects.PlanProjectController{},
			),
		),
		beego.NSNamespace("/project/case",
			beego.NSInclude(
				&cases.CaseController{},
			),
		),
		beego.NSNamespace("/project/case/pkg",
			beego.NSInclude(
				&cases.CasePkgController{},
			),
		),
		beego.NSNamespace("/project/task/case",
			beego.NSInclude(
				&projects.TaskCaseController{},
			),
		),
		beego.NSNamespace("/project/doc",
			beego.NSInclude(
				&projects.DocController{},
			),
		),
		beego.NSNamespace("/project/needs/swimlane",
			beego.NSInclude(
				&projects.NeedsSwimlaneProjectController{},
			),
		),
	)
	beego.AddNamespace(ns)
}
